<template>
  <div class="permission-denied">
    <el-result
      icon="warning"
      title="权限不足"
      :sub-title="subTitle"
    >
      <template #extra>
        <el-button type="primary" @click="goToPermissionsInfo">
          查看权限说明
        </el-button>
        <el-button @click="goBack">返回</el-button>
      </template>
    </el-result>
  </div>
</template>

<script>
import { useRouter } from 'vue-router'

export default {
  name: 'PermissionDenied',
  props: {
    subTitle: {
      type: String,
      default: '您没有访问此功能的权限，请检查您的账户权限或联系管理员。'
    }
  },
  setup() {
    const router = useRouter()

    const goToPermissionsInfo = () => {
      router.push('/permissions')
    }

    const goBack = () => {
      router.go(-1)
    }

    return {
      goToPermissionsInfo,
      goBack
    }
  }
}
</script>

<style scoped>
.permission-denied {
  padding: 40px 20px;
  min-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
</style>

